//
//  COperation.h
//  Delicious
//
//  Created by yilong zhang on 11-11-21.
//  Copyright 2011年 __MyCompanyName__. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "CDownLoadManager.h"

@class CTask;  
@class CNetWorkRequest;
@class COperation;
@protocol NetWorkRequestDelegate;

//=========================================================================================================================

@protocol OperationDelegate <NSObject>

@optional
-(void)DidOperationFinished:(COperation*)op Data:(NSData*)data Other:(id)other UserInfo:(id)userinfo;
-(void)DidOperationError:(COperation*)op Error:(NSError*)error Other:(id)other UserInfo:(id)userinfo;
-(void)DidOperationTimeOut:(COperation*)op Other:(id)other UserInfo:(id)userinfo;

@end

//=========================================================================================================================

@protocol TaskDelegate <NSObject>

@optional
-(void)DidTaskFinished:(COperation*)op;

@end

//=========================================================================================================================

@interface COperation : NSOperation <NetWorkRequestDelegate>

@property (nonatomic, assign)   id<TaskDelegate>        m_TaskDelegate;

@property (nonatomic, assign)   CNetWorkRequest         *m_UrlConnection;   //用于向网络请求数据
@property (nonatomic, retain)   CTask                   *m_Task;
@property (nonatomic, assign)   id<OperationDelegate>   m_Sponsor;
//new 
@property (nonatomic, assign)   BOOL              m_bIsCancel;

-(id)initWithID:(int)ID Delegate:(id)delegate;

-(void)SetOperation:(CTask*)task Request:(CNetWorkRequest*)request;
-(void)CancelDelegate;

-(void)StartOperation; 
-(void)cancelOperation;

@end

